/*    */ package dm.jdbc.driver;
/*    */ 
/*    */ import dm.jdbc.dbaccess.DBError;
/*    */ import java.io.IOException;
/*    */ import java.io.OutputStream;
/*    */ import java.sql.SQLException;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class DmdbOutputStream
/*    */   extends OutputStream
/*    */ {
/*    */   private DmdbBlob blob;
/*    */   private DmdbClob clob;
/*    */   private int typeFlag;
/* 36 */   private long position = 0L;
/*    */   
/*    */   public DmdbOutputStream(Object o, long p) throws SQLException {
/* 39 */     if ((o instanceof DmdbBlob)) {
/* 40 */       this.blob = ((DmdbBlob)o);
/* 41 */       this.typeFlag = 0;
/* 42 */     } else if ((o instanceof DmdbClob)) {
/* 43 */       this.clob = ((DmdbClob)o);
/* 44 */       this.typeFlag = 1;
/*    */     } else {
/* 46 */       throw new SQLException("Only permit DmdbBlob and DmdbClob object");
/*    */     }
/* 48 */     this.position = p;
/*    */   }
/*    */   
/*    */   public void write(int a) throws IOException {
/* 52 */     byte[] tempByte = new byte[1];
/* 53 */     tempByte[0] = ((byte)a);
/* 54 */     write(tempByte, 0, 1);
/*    */   }
/*    */   
/*    */   public void write(byte[] b, int off, int len) throws IOException {
/* 58 */     if (off < 0) {
/* 59 */       throw new IndexOutOfBoundsException(new Integer(off).toString());
/*    */     }
/* 61 */     if (len < 0) {
/* 62 */       throw new IndexOutOfBoundsException(new Integer(len).toString());
/*    */     }
/* 64 */     if (off + len > b.length) {
/* 65 */       throw new IndexOutOfBoundsException(
/* 66 */         new Integer(off + len).toString());
/*    */     }
/*    */     try {
/* 69 */       if (this.typeFlag == 0) {
/* 70 */         this.blob.setBytes(this.position, b, off, len);
/* 71 */         this.position += len;
/* 72 */       } else if (this.typeFlag == 1) { byte[] tempByte;
/*    */         byte[] tempByte;
/* 74 */         if ((len == b.length) && (off == 0)) {
/* 75 */           tempByte = b;
/*    */         } else {
/* 77 */           tempByte = new byte[len];
/* 78 */           System.arraycopy(b, off, tempByte, 0, len);
/*    */         }
/* 80 */         String tempStr = new String(tempByte);
/* 81 */         this.clob.setString(this.position, tempStr, 0, tempStr.length());
/* 82 */         this.position += tempStr.length();
/*    */       } else {
/* 84 */         throw new SQLException(
/* 85 */           "Fatal error occured in DmdbOutputStream ");
/*    */       }
/*    */     } catch (SQLException e) {
/* 88 */       DBError.SQLToIOException(e);
/*    */     }
/*    */   }
/*    */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\driver\DmdbOutputStream.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */